//
//  StagePrototypes.cpp
//  airfight
//
//  Created by aaron more on 12-9-12.
//  Copyright (c) 2012年 moonriver. All rights reserved.
//

#include <iostream>
#include "StagePrototypes.h"


StagePrototypes* StagePrototypes::s_SharedStagePrototypes = NULL;

StagePrototypes* StagePrototypes::getInstance()
{
    static bool s_bFirstUseStagePrototypes = true;
    if (NULL == s_SharedStagePrototypes) {
        s_SharedStagePrototypes = new StagePrototypes();
        s_bFirstUseStagePrototypes = false;
        s_SharedStagePrototypes->init();
    }
    return s_SharedStagePrototypes;
    
}

StagePrototypes::StagePrototypes()
{
    stagePrototype_Dict = NULL;
}

bool StagePrototypes::init()
{
    stagePrototype_Dict = CCDictionary::create();
    stagePrototype_Dict->retain();
    return true;
}

StagePrototypes::~StagePrototypes()
{
    CC_SAFE_RELEASE(stagePrototype_Dict);
}

void StagePrototypes::addStage(Stage* p_stage)
{
    int stage_id = p_stage->getStageID();
    stagePrototype_Dict->setObject(p_stage, stage_id);
}

Stage* StagePrototypes::getStageByID(int p_id)
{
    CCObject* tmp = stagePrototype_Dict->objectForKey(p_id);
    
    if(tmp){
        return (Stage*)tmp;
    }else{
        return NULL;
    }
}
